<?php

namespace falcon5\inc\Infrastructure\Services\Falcon5;

use falcon5\inc\Exceptions\RemoteServiceException;
use lucatume\DI52\ContainerException;

trait AdminTrait
{
    /**
     * @param array $params
     * @return mixed
     * @throws ContainerException
     * @throws RemoteServiceException
     */
    public function checkUserLanguageEditPermission(array $params)
    {
        // 调用远程API验证用户权限
        $response = $this->getClient()->checkUserLanguageEditPermission($params);
        
        $content = $response->getBody()->getContents();
        
        if ($response->getStatusCode() != 200) {
            throw new RemoteServiceException($content, $response->getStatusCode());
        }
        
        return json_decode($content, true);
    }
}